<template>
    <view>profile</view>
    <navigator open-type="navigateBack" delta=3>返回上一页</navigator>
    <button @click="hadleGlobalEvent">$emit</button>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { getCurrentInstance } from 'vue';

console.log('getCurrentPagers', getCurrentPages());
console.log('getCurrentInstance', getCurrentInstance());
onLoad((options) => {
    console.log(options);
    // 小程序专有api ,h5无法获取到
    const eventChannel = getCurrentInstance().ctx.getOpenerEventChannel();
    eventChannel.emit('sayHello', 111)
    eventChannel.emit('sayHello', 111)
    eventChannel.emit('sayHello', 111)
    eventChannel.emit('sayHello', 111)

    eventChannel.on('sayWorld', (num) => {
        console.log('sayWorld', num);
    })
})

const hadleGlobalEvent = () => {
    uni.$emit('aaa', 3, 2, 1)
}


</script>
